package com.casicloud.manage.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.casicloud.manage.mapper.AuthorityMapper;
import com.casicloud.manage.model.Authority;
import com.casicloud.manage.service.AuthorityService;
import com.common.sub.util.PageUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class AuthorityServiceImpl implements AuthorityService {
	
	@Autowired
	private AuthorityMapper authorityMapper;

	@Override
	public List<Authority> findByList(Authority authority) {
		return authorityMapper.findByList(authority);
	}

	@Override
	public void save(Authority authority) {
		
		authority.setCreateTime(new Date());
		
		authorityMapper.save(authority);
		
	}

	@Override
	public int delete(Authority authority) {
		return authorityMapper.delete(authority);
	}

	@Override
	public PageInfo<Authority> findByPage(PageUtil pageUtil, Authority authority) {
		Page<Authority> p = PageHelper.startPage(pageUtil.getPage(), pageUtil.getRows());
		authorityMapper.findByList(authority);
		return new PageInfo<Authority>(p);
	}

	@Override
	public Authority findByOne(Authority authority) {
		return authorityMapper.findByOne(authority);
	}

	@Override
	public int update(Authority authority) {
		authority.setCreateTime(new Date());
		return authorityMapper.update(authority);
	}

	@Override
	public List<Authority> findByIds(Integer... ids) {
		return authorityMapper.findByIds(ids);
	}

}
